<!--缺陷类型组件 -->
<template>
  <div >
		<div>
			<el-input placeholder="关键词" v-model="keyword"style="width: 200px;"></el-input>
			<el-button type="primary" size="mini" @click="load" >搜素</el-button>
			<el-button type="primary" size="mini" @click="open" >添加</el-button>
		</div>
		 <el-table :data="datas"style="width: 100%" >
			<el-table-column type="selection"  ></el-table-column>
			<el-table-column prop="typeCode" label="缺陷类型Id"></el-table-column>
			<el-table-column prop="typeDesc" label="缺陷类型名"></el-table-column>
			<el-table-column prop="moduleState" :formatter="state" label="缺陷类型状态"></el-table-column>
			<el-table-column prop="createBy" label="缺陷创建人"></el-table-column>
			<el-table-column prop="createTime" label="缺陷创建时间"></el-table-column>
			<el-table-column prop="modifyBy" label="缺陷修改人"></el-table-column>
			<el-table-column prop="modifyTime" label="修改时间"></el-table-column>
		
			<el-table-column  label="操作">
				<template slot-scope="scope">
					<el-button type="primary" icon="el-icon-edit" size="mini"
					 @click="openchange(scope.row)" >修改</el-button>
					
				</template>
			</el-table-column>
		</el-table>
		
		 <!-- 添加缺陷类型的弹出框-->
		 <el-dialog title="添加缺陷类型" :visible.sync="dialogTableVisible " >
		  <el-form  label-width="80px"  >
		    <el-form-item label="类型描述">
		      <el-input v-model="addTypeParam.typeDesc"></el-input>
		    </el-form-item>
		
		    <el-form-item label="创建人">
		      <el-input v-model="addTypeParam.createBy"></el-input>
		    </el-form-item>
		    <el-form-item label="创建时间" >
				<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss"type="date"
				 placeholder="选择日期" v-model="addTypeParam.createTime">
		   
		 </el-date-picker>
		 </el-form-item>
		</el-form>
		   <div slot="footer" >
		         <el-button @click="dialogTableVisible=false">取 消</el-button>
		         <el-button type="primary" @click="addType">提交</el-button>
		    </div>
		 </el-dialog>
		 
		 <!-- 修改缺陷类型的弹出框-->
		  <el-dialog title="修改缺陷类型" :visible.sync="changeTableVisible " >
		   <el-form  label-width="80px"  >
		     <el-form-item label="类型描述">
		       <el-input v-model="changeTypeParam.typeDesc"></el-input>
		     </el-form-item>
		 
		     <el-form-item label="类型状态">
		       <el-input v-model="changeTypeParam.moduleState"  placeholder="0不可用 1 可用"></el-input>
		     </el-form-item>
			 <el-form-item label="创建人">
			   <el-input v-model="changeTypeParam.createBy" 
			   :disabled="changeTypeParam.createBy !=null"></el-input>
			 </el-form-item>
		     <el-form-item label="创建时间" >
		 		<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss"type="date"
		 		 placeholder="选择日期" 
				 :disabled="changeTypeParam.createTime!=null"
				  v-model="changeTypeParam.createTime">
				</el-date-picker>
			</el-form-item>
			<el-form-item label="修改人">
			  <el-input v-model="changeTypeParam.modifyBy"></el-input>
			</el-form-item>
			<el-form-item label="修改时间" >
				<el-date-picker  value-format="yyyy-MM-dd HH:mm:ss"type="date"
				 placeholder="选择日期" v-model="changeTypeParam.modifyTime">
				</el-date-picker>
			</el-form-item>
		 </el-form>
		    <div slot="footer" >
		          <el-button @click="changeTableVisible=false">取 消</el-button>
		          <el-button type="primary" @click="changForm">提交</el-button>
		     </div>
		  </el-dialog>
		 
		
		
		
  </div>
</template>

<script>
export default {
  name: 'ststem-defecttype',
  data() {
  		return {
  			datas:[],
			keyword:null,
			dialogTableVisible:false,
			changeTableVisible:false,
			addTypeParam:{
				typeDesc:null,
				
				createBy:null,
				createTime:null
			},
			changeTypeParam:{
				typeCode:null,
				typeDesc:null,
				createBy:null,
				createTime:null,
				moduleState:null,
				modifyBy:null,
				modifyTime:null
			}
  		}
  	},
  methods:{
	  openchange(row){
		  this.changeTableVisible=true;
		  this.changeTypeParam.typeCode=row.typeCode,
		  this.changeTypeParam.typeDesc=row.typeDesc,
		  this.changeTypeParam.createBy=row.createBy,
		  this.changeTypeParam.createTime=row.createTime,
		  this.changeTypeParam.moduleState=row.moduleState,
		  this.changeTypeParam.modifyBy=row.modifyBy,
		  this.changeTypeParam.modifyTime=modifyTime
		  
	  },
	  changForm(){
			  
		  this.$http.post("/type/save",this.changeTypeParam).then(resp =>{
			  if(resp.data.flag==true){
				  this.changeTableVisible=false;
				  this.load();
			  }
		  })
	  },
	  state(row, column, cell){
	  		 if(cell==0){
	  		 	return "不可用";
	  		 }else if(cell==1){
	  		 	return "可用";
	  		 }
	  },
	  
	  load(){
		  const param= "?keyword="+this.keyword
		  this.$http.get("/type/query"+param).then(resp =>{
			  console.log("vvvvvvvvvvv"+this.keyword)
			  if(resp.data.flag=true){
				  console.log(resp.data.data)
				  this.datas= resp.data.data;
			  }
		  })
	  },
	  open(){
		this. dialogTableVisible=true; 
		 
	  },
	  addType(){
		  this.$http.post("/type/add",this.addTypeParam).then(resp => {
			  if(resp.data.flag=true){
				  console.log("mmmm"+resp.data.data)
			  }
			  this.addTypeParam={};
		  })
		  this.load();
	  }
	 
  },
  created() {
  	this.load();
  }
  
}
</script>
<style>
	
</style>

